﻿using Lanbt.Core.Entity.Verification;
using System.ComponentModel.DataAnnotations;
using static Lanbt.Core.Entity.Enums.QuartzEnums;

namespace Lanbt.Core.Entity.Dto.quartz
{
    /// <summary>
    /// 添加任务参数
    /// </summary>
    public class InsertJobInput : QuartzDtoInput
    {
        /// <summary>
        /// 开始执行时间
        /// </summary>
        [Required(ErrorMessage = "请选择开始时间")]
        [IsDateTime]
        public string StartTime { get; set; }

        /// <summary>
        /// 结束执行时间
        /// </summary>
        [IsDateTime]
        public string? EndTime { get; set; }

        /// <summary>
        /// 任务类型（API = 1，邮箱 = 2）
        /// <see cref="Enums.QuartzEnums.JobType"/>
        /// </summary>
        [Range(1, 2, ErrorMessage = "任务类型不合法")]
        public JobType JobType { get; set; }

        /// <summary>
        /// 触发器类型<see cref="Enums.QuartzEnums.TriggerType"/>
        /// </summary>
        [Range(1, 2, ErrorMessage = "触发器类型不合法")]
        public TriggerType TriggerType { get; set; }

        /// <summary>
        /// 说明
        /// </summary>
        [MaxLength(120, ErrorMessage = "说明字符串超过规定长度")]
        public string Description { get; set; }

        /// <summary>
        /// 邮箱通知
        /// </summary>
        public MailNoticeType MailNotice { get; set; }

        #region Trigger Params

        #region Cron

        /// <summary>
        /// Cron值
        /// </summary>
        [IsCron(ErrorMessage = "Cron值不合法")]
        public string CronValue { get; set; }

        #endregion Cron

        #region Simple

        /// <summary>
        /// 间隔时间
        /// </summary>
        public int? IntervalTime { get; set; }

        /// <summary>
        /// 执行次数
        /// </summary>
        public int? IntervalCount { get; set; }

        #endregion Simple

        #endregion Trigger Params

        #region Job Params

        #region API

        /// <summary>
        /// 接口地址
        /// </summary>
        public string ApiUrl { get; set; }

        /// <summary>
        /// 接口调用方法
        /// <see cref="Enums.QuartzEnums.APIHttpMethod"/>
        /// </summary>
        public APIHttpMethod? APIHttpMethod { get; set; }

        /// <summary>
        /// 头部参数
        /// </summary>
        public string Head { get; set; }

        /// <summary>
        /// Body参数
        /// </summary>
        public string FormBody { get; set; }

        #endregion API

        #region Email

        /// <summary>
        /// 收件邮箱（多个英文逗号【,】隔开）
        /// </summary>
        public string ReceiveEmails { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public string Content { get; set; }

        #endregion

        #endregion Job Params
    }
}
